/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pos.Driving.Path.Segments;

import javax.vecmath.*;
import pos.Driving.Path.*;
import pos.Driving.Path.Segment.Segment;

/**
 * 1号线区间1 莘庄-外环路
 * @author Administrator
 */
public class Segment_01_01 extends Segment{

    public Segment_01_01() {
        super(1, "1号线区间1", "莘庄-外环路", "Model.Segments.01_01"
                , new Point3d(0,0,0));
    }

    @Override
    protected void initRail() {
        this.addPathSection(0, 0, 1200, new Followable(){
            public PosPoint makePath(PosPoint pos) {
                PosPoint ppOut=new PosPoint(pos);
                ppOut.pos=new Point3d(ppOut.d-300,1,3);
                ppOut.AngH=0;
                ppOut.AngV=0;
                if (ppOut.d>400 && ppOut.d<650)
                    ppOut.PATH_TYPE=PosPoint.PATH_STATION;
                else
                    ppOut.PATH_TYPE=PosPoint.PATH_GROUND;
                if (ppOut.isSideway && ppOut.d>200 && ppOut.d<220)
                    ppOut.path_ID=2;
                return ppOut;
            }
        });
        
        this.addPathSection(2, 150, 350, new Followable(){                      //单渡线
            public PosPoint makePath(PosPoint pos) {
                PosPoint ppOut=new PosPoint(pos);
                if (pos.d>200 && pos.d<300){
                    double t=((pos.d-200)/100-0.5)*Math.PI,
                            t1=((pos.d+0.1-200)/100-0.5)*Math.PI;
                    ppOut.pos=new Point3d(ppOut.d-300,1,-3*Math.sin(t));
                    ppOut.AngV=Math.atan((Math.sin(t)-Math.sin(t1))/0.1);
                }else{
                    if (pos.d<200)
                        ppOut.pos=new Point3d(ppOut.d-300,1,3);
                    else
                        ppOut.pos=new Point3d(ppOut.d-300,1,-3);
                    ppOut.AngV=0;
                }
                ppOut.AngH=0;
                ppOut.PATH_TYPE=PosPoint.PATH_GROUND;
                if (ppOut.d>300){
                    ppOut.path_ID=1;
                    ppOut.isSideway=false;
                }
                else if(ppOut.d<200){
                    ppOut.path_ID=0;
                    ppOut.isSideway=false;
                }
                return ppOut;
            }
        });
        
        
        this.addPathSection(1, 0, 1200, new Followable(){
            public PosPoint makePath(PosPoint pos) {
                PosPoint ppOut=new PosPoint(pos);
                ppOut.pos=new Point3d(ppOut.d-300,1,-3);
                ppOut.AngH=0;
                ppOut.AngV=0;
                if (ppOut.d>400 && ppOut.d<650)
                    ppOut.PATH_TYPE=PosPoint.PATH_STATION;
                else
                    ppOut.PATH_TYPE=PosPoint.PATH_GROUND;
                if (ppOut.isSideway && ppOut.d>280 && ppOut.d<300){
                    ppOut.path_ID=2;
                   // System.out.println(ppOut.d);
                }
                return ppOut;
            }
        });
    }

}
